package GradeTopN;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

public class GradePartition extends Partitioner<GradeTopNFlowBean, Text> {
    @Override
    public int getPartition(GradeTopNFlowBean flowBean, Text text, int i){
        String grade = flowBean.getGrade();
        int partition = 5;

        switch(grade){
            case "A":
                partition = 0;
                break;
            case "B":
                partition =1;
                break;
            case "C":
                partition = 2;
                break;
            case "D":
                partition = 3;
                break;
            default:
                partition = 4;
        }

        return partition;
    }
}
